/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.notation;

import org.jfonia.connect5.basics.BasicValueNode;
import org.jfonia.connect5.basics.MutableValueNode;
import org.jfonia.connect5.numerical.UnidirectionalIntSumRelation;
import org.jfonia.connect5.relations.Equal;
import org.jfonia.model.elements.IStaffElement;
import org.jfonia.model.elements.MusicalElement;

/**
 *
 * @author Rik Bauwens
 */
public class Tie extends MusicalElement implements IStaffElement
{
        private ObservableNoteOrRest left;
        private ObservableNoteOrRest right;

        private Equal<Integer> leftRelation;
        private Equal<Integer> rightRelation;

        public Tie()
        {
                super(0);
        }

        public ObservableNoteOrRest getLeft()
        {
                return left;
        }

        public ObservableNoteOrRest getRight()
        {
                return right;
        }

        public Tie setLeft(ObservableNoteOrRest noteOrRest)
        {
                if(leftRelation != null)
                        leftRelation.switchOff();
                leftRelation = new Equal<Integer>(noteOrRest.getBeginNode(), this.begin);
                left = noteOrRest;
                return this;
        }

        public Tie setRight(ObservableNoteOrRest noteOrRest)
        {
                if(rightRelation != null)
                        rightRelation.switchOff();
                rightRelation = new Equal<Integer>(noteOrRest.getBeginNode(), this.end);
                right = noteOrRest;
                return this;
        }

        private void setRelations()
        {
                if(left == null)
                {
                        //Both left and right null
                        if(right == null)
                        {

                        }
                        //Only left null
                        else
                        {

                        }
                }
                else
                {
                        //Only right null
                        if(right == null)
                        {

                        }
                        //Left and right both not null
                        else
                        {

                        }
                }

        }

        @Override
        public Tie clone()
        {
                Tie tie = new Tie();
                //chord.setChord(chordNode.getValue());
                return tie;
        }
}
